package expriment3_bag;

public class Ten {
    public static void main(String[] args) {
        System.out.println("主对角线元素之和计算：");
        double sum=0;
        int array[][]={{1,2,3},{4,5, 6},{7,7,8}};
        for(int i=0;i<3;i++)
            for(int j=0;j<3;j++){
                if(i==j)
                    sum=sum + array[i][j];
            }
        System.out.println(sum);
    }
}
